<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/layui.css" media="all">
</head>
<body>
	<form class="layui-form">

		<div class="layui-inline">
			<label class="layui-form-label">员工编号:</label>
			<div class="layui-input-block">
				<input type="text" id="empno" name="empno" 
					autocomplete="off" placeholder="请输入..." class="layui-input" readonly>
			</div>
		</div>
		<br> <br> <br>
		<div class="layui-inline">
			<label class="layui-form-label">员工姓名:</label>
			<div class="layui-input-block">
				<input type="text" id="ename" name="ename" 
					autocomplete="off" placeholder="请输入..." class="layui-input" readonly>
			</div>
		</div>
		<br> <br> <br>
		<div class="layui-inline">
			<label class="layui-form-label">员工职位:</label>
			<div class="layui-input-block">
				<input type="text" id="job" name="job"  autocomplete="off"
					placeholder="请输入..." class="layui-input" readonly>
			</div>
		</div>
		  <div class="layui-inline">
      <label class="layui-form-label">入职日期:</label>
      <div class="layui-input-inline">
        <input type="text" id="hiredate" name="hiredate"  
        placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" readonly>
      </div>
    </div>
		<br> <br> <br>
		<div class="layui-inline">
			<label class="layui-form-label">员工工资:</label>
			<div class="layui-input-block">
				<input type="text" id="sal" name="sal"  autocomplete="off"
					placeholder="请输入..." class="layui-input" readonly>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">员工奖金:</label>
			<div class="layui-input-block">
				<input type="text" id="comm" name="comm"  autocomplete="off"
					placeholder="请输入..." class="layui-input" readonly>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">工资证照:</label>
			<div class="layui-input-block">
				<input type="text" id="id_photo" name="id_photo" 
					autocomplete="off" placeholder="请输入..." class="layui-input" readonly>
			</div>
		</div>
		<br> <br> <br>
		<div class="layui-form-item">
			<label class="layui-form-label">部门名:</label>
			<div class="layui-input-block">
				<select id="dept_id" name="dept_id">
					<option value="" selected="selected">请选择</option>
					<option value="1">财务</option>
					<option value="2">人事</option>
					<option value="3">ceo</option>
				</select>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="layui.all.js"></script>
	<script type="text/javascript" src="lay/jquery.min.js"></script>
	<script>
	$("#dept_id").each(function() {
        // this代表的是<option></option>，对option再进行遍历
        $(this).children("option").each(function() {
            // 判断需要对那个选项进行回显
            if (this.value == 2) {
    
            }
        });
    })
	String.prototype.getParameter = function (key) {  
	    var re = new RegExp(key + '=([^&]*)(?:&)?');  
	    return this.match(re) && this.match(re)[1];  
	}; 
	function getParamterByKey(key) {
		   return location.href.getParameter(key); 
		}
	
	
	
	$(function() {
		$.post(
				"echo",
				"id="+getParamterByKey("id"),
				function(data) {
					if (data) {
						$("#empno").val(data.data[0].id);
						$("#ename").val(data.data[0].ename);
						$("#job").val(data.data[0].job);
						$("#hiredate").val(data.data[0].hiredate);
						$("#sal").val(data.data[0].sal);
						$("#comm").val(data.data[0].comm);
						$("#id_photo").val(data.data[0].id_photo);
						i=(data.data[0].dept_id);
						
					}
				},
				"json"
				);
	})
	</script>
</body>
</html>